home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13590 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  84 lines

  1. Path: admaix.sunydutchess.edu!ub!newserve!rebecca!rpi!not-for-mail
  2. From: cvjetko@PROBLEM_WITH_INEWS_GATEWAY_FILE.uni-erlangen.de (Miljenko Cvjetko)
  3. Newsgroups: comp.lang.c++,comp.lang.c++.moderated,comp.sys.hp.hpux
  4. Subject: [Q] gcc 2.7.2 + STL + HP_UX 9.05 = memory_leak ?
  5. Date: 25 Mar 1996 13:22:06 -0000
  6. Organization: Regionales Rechenzentrum Erlangen, Germany
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: kanze@lts.sel.alcatel.de
  9. Message-ID: <4j66lu$olu@netlab.cs.rpi.edu>
  10. NNTP-Posting-Host: netlab.cs.rpi.edu
  11. X-Original-Date: 25 Mar 1996 12:12:48 GMT
  12.  
  13. I was testing storing ptrs in STL container when I found
  14. out a memory-leak in STL implementation in following 
  15. example:
  16.  
  17. # include <list.h>           // STL list
  18. # include <stdlib.h>
  19.  
  20. class X
  21. {
  22.  protected:
  23.   list<int> nodes_;  // this line causes 
  24.                      // memory leak problems!!!
  25.                      //     under HP_UX 9.05
  26.                      // not under Borland C/C++ + DOS
  27. };
  28.  
  29. void f()
  30. {
  31.  X x1;
  32. }
  33.  
  34. int main()
  35. {
  36.  memorymap(1);
  37.  f();
  38.  memorymap(1);   // list is out of scope 
  39.  return 0;
  40. }
  41. - ------------------------------------------
  42. Result:
  43.  
  44. arenastart               :          0
  45. arenaend                 :          0
  46. # of blocks              :          0
  47. # of free blocks         :          0
  48. # of used blocks         :          0
  49. # of smblk blks          :          0
  50. total space used         :          0
  51. space in free blocks     :          0
  52. space in used blocks     :          0
  53. space in smblk blocks    :          0
  54. 1073748164: node block 8192
  55. 1073756356: free 1848
  56.  
  57. arenastart               : 1073748164
  58. arenaend                 : 1073758204
  59. # of blocks              :          2
  60. # of free blocks         :          1
  61. # of used blocks         :          1
  62. # of smblk blks          :          0
  63. total space used         :      10040
  64. space in free blocks     :       1848
  65. space in used blocks     :       8192
  66. space in smblk blocks    :          0
  67. - -------------------------------------------
  68. In addition, this code was compiled under
  69. BC 4.5 and had no memory leak! Am I
  70. misinterpreting memorymap() function call?
  71. Same was with some other containers (set,vector).
  72. Any suggestions?
  73.  
  74. Thanx in advance
  75. Regards 
  76. m.
  77.  
  78.  
  79.  
  80.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  81.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  82.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  83.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  84.